Ext.namespace("SMeeting");

SMeeting.View3 = function(p) {
	this.parentWin=p
	this.winMsg=null;
	thiz=this;
	
	this.txtRemind=new Ext.form.Hidden({name:'remind'});
	this.hdSuperviseId = new Ext.form.Hidden({name:'superviseId'});
	
	this.txtTitle = new Ext.form.TextField({
        fieldLabel: '会议名称',
        width: 540,
        name:'superviseTitle',
        disabled:true
    });
	this.txtDispatchDept = new Ext.form.TextField({
		fieldLabel: '发文部门',
		name:'dispatchDeptName',
		disabled:true,
		width: 110
	});
	this.txtAuditor = new Ext.form.TextField({
		fieldLabel: '批示人',
		name:'auditor',
		disabled:true,
		width: 110
	});
	this.txtDocDate = new Ext.form.TextField({
    	fieldLabel: '批示日期',
    	name:'auditDate',
		disabled:true,
		width:110
	});
	this.txtNotion = new Ext.form.TextArea({
		fieldLabel: '领导批示意见',
		name:'notion',
		width: 550,
		disabled:true,
		height: 30
	});
    this.txtPrincipal = new Ext.form.TextField({
		fieldLabel: '阅处负责人',
		name:'managerName',
		disabled:true,
		width: 110
	});
	this.txtInspector = new Ext.form.TextField({
		fieldLabel: '阅处人',
		name:'inspectorName',
		disabled:true,
		width: 110
	});
	this.txtInspectDate =  new Ext.form.TextField({
    	fieldLabel: '阅处日期',
    	disabled:true,
    	name:'completeDate',
    	width: 110,
		format: 'Y-m-d'
	});
	this.txtContent = new Ext.form.TextArea({
		fieldLabel: '发文内容',
		width:550,
		height:30,
		name:'superviseContent',
		disabled:true
	});
	this.txtReceiveDept = new Ext.form.TextField({
		fieldLabel: '收文部门',
		name:'receiveDeptName',
		disabled:true,
		width: 110
	});
	this.txtFulfill = new Ext.form.TextArea({
		fieldLabel: '落实情况',
		name:'fulfill',
		disabled:true,
		width: 550,
		height:35
	});
	
	this.form = new Ext.FormPanel({
		bodyStyle: 'padding: 5px 5px 0',
        labelWidth: 70,
        labelAlign: 'right',
        region:'north',	
		height: 230,
		frame:true,
		items: [ this.txtTitle,
        	{ layout: 'column', border: false, defaults: {layout: 'form', border: false},
	        	items: [ { columnWidth: .33, items: [this.txtDispatchDept] },
	        	         { columnWidth: .33, items: [this.txtAuditor]} ]
	    },this.txtNotion,{ layout: 'column', border: false, defaults: {layout: 'form', border: false},
	        	items: [ { columnWidth: .33, items: [this.txtDocDate]},
	        	         { columnWidth: .33, items: [this.txtInspector] },
	        	         { columnWidth: .33, items: [this.txtPrincipal]} ]
	    },this.txtContent,{ layout: 'column', border: false, defaults: {layout: 'form', border: false},
	        	items: [ { columnWidth: .33, items: [this.txtInspectDate]},
	        	         { columnWidth: .33, items: [this.txtReceiveDept]} ]
	    },this.txtFulfill,this.hdSuperviseId]
    });
	this.store2 = new Ext.data.JsonStore({
	    url: '../superviseMeeting/listMeetingTask.form?timesnap=' + Date.parse(new Date()),
	    root: 'result',
	    totalProperty: 'total',
        remoteSort: true,
	    fields: ['auditId','superviseId','auditContent','auditorId','auditDate',
	    'auditState','inspectorId','inspectorName','dispatchDate','feedback','completeDate',
	    'content','auditorName']
	});
	//this.store.setDefaultSort('taskFeedbackId', 'desc');
	this.renderTaskStatus = function(value){
		return OMS.TASKSEXESTATUS[value];
	}
	this.renderState = function(value){
		return OMS.SUPERVISE_STATE[value];
	};
	this.renderSend = function(value){
		return '<a href="javascript:thiz.onSendMsg('+value+')">催办</a>';
	}
	this.columns2 = [	
		{header: '派发ID', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'auditId'},
		{header: '督办ID', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'superviseId'},
		{header: '派发意见', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'auditContent'},
		{header: '派发人ID', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'auditorId'},
		{header: '派发人', sortable: true, align: 'center',width: 20,dataIndex: 'auditorName'},
		{header: '任务派发时间', sortable: true, align: 'right',width: 20,dataIndex: 'dispatchDate'},
		{header: '反馈日期', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'auditDate'},
		{header: '状态', sortable: true, align: 'center',width: 20,dataIndex: 'auditState',renderer:this.renderState},
		{header: '阅处人id', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'inspectorId'},
		{header: '阅处人名称', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'inspectorName'},		
		{header: '反馈情况', sortable: true, align: 'center',dataIndex: 'feedback'},
		{header: '完成期限', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'completeDate'},
		{header: '操作', align: 'center',width: 10,dataIndex: 'auditorId',renderer:this.renderSend}
	];
	this.grid2 = new Ext.grid.EditorGridPanel({
		title:'任务派发情况',
		region: 'center',
		cm: new Ext.grid.ColumnModel(this.columns2),
		store:this.store2,
		height: 180,
		viewConfig: { forceFit: true },
        collapsible:true
	});	
	SMeeting.View3.superclass.constructor.call(this, {
		title: '查看会议',        
        width:700,
		height:420,
		resizable: false,
        modal: true,
        autoScroll: true,
		closeAction:'hide',
        items: [this.form,this.grid2],
        buttons: [{
            text: '关闭',
            scope: this,
            handler: function() {
	        	this.hide();
        	}
        }],
        buttonAlign:'center'
	});
};
Ext.extend(SMeeting.View3, Ext.Window, {
	initWin:function(data){		
		this.form.getForm().setValues(data);
		
		this.grid2.store.load({
			params:{superviseId:data.superviseId}
		});	
	},
	onSendMsg:function(value){		
		scope=this;
		if(this.winMsg==null)
			this.winMsg=new Message.Msg(function(){
				scope.txtRemind.setValue(scope.winMsg.txtRemind);
				scope.sendMsg(value);
			},'你确实要催办吗？');
		this.winMsg.show();
	},
	sendMsg:function(value){
		var conn = new Ext.data.Connection({
  			url:'../superviseMeeting/auditMsg.form?timesnap=' + Date.parse(new Date()),
  			method:'post'
  		})
  		var param={'userId':value,'superviseId':this.hdSuperviseId.getValue(),
  					'remind':this.txtRemind.getValue()};
  		//alert(Ext.util.JSON.encode(param));		
		Utils.request(conn,{
  			params:param,
  			scope:this,
  			success:function(data){
  				Utils.info2();
  			}
  		});
	}
});